home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / tar.gnu / tar-dist / getdate.y < prev    next >
Encoding:
Text File  |  1990-01-11  |  13.1 KB  |  607 lines

  1. %token ID MONTH DAY MERIDIAN NUMBER UNIT MUNIT SUNIT ZONE DAYZONE AGO
  2. %{
  3.     /*     Originally from: Steven M. Bellovin (unc!smb)    */ 
  4.     /*    Dept. of Computer Science            */
  5.     /*    University of North Carolina at Chapel Hill    */
  6.     /*    @(#)getdate.y    2.17    11/30/87            */
  7.  
  8. /* #include "defs.h" JF not used any more */
  9. #include <sys/types.h>
  10. #ifdef USG
  11. struct timeb
  12. {
  13.     time_t    time;
  14.     unsigned short millitm;
  15.     short    timezone;
  16.     short    dstflag;
  17. };
  18. #else
  19. #include <sys/timeb.h>
  20. #endif
  21. #include <ctype.h>
  22.  
  23. #if defined(BSD4_2) || defined (BSD4_1C)
  24. #include <sys/time.h>
  25. #else /* sane */
  26. #include <time.h>
  27. #endif /* sane */
  28.  
  29. #ifdef __GNUC__
  30. #define alloca __builtin_alloca
  31. #else
  32. #ifdef sparc
  33. #include <alloca.h>
  34. #endif
  35. #endif
  36.  
  37. #define    NULL    0
  38. #define daysec (24L*60L*60L)
  39.     static int timeflag, zoneflag, dateflag, dayflag, relflag;
  40.     static time_t relsec, relmonth;
  41.     static int hh, mm, ss, merid, day_light;
  42.     static int dayord, dayreq;
  43.     static int month, day, year;
  44.     static int ourzone;
  45. #define AM 1
  46. #define PM 2
  47. #define DAYLIGHT 1
  48. #define STANDARD 2
  49. #define MAYBE    3
  50.  
  51. static time_t timeconv();
  52. static time_t daylcorr();
  53. static lookup();
  54.  
  55. %}
  56.  
  57. %%
  58. timedate:         /* empty */
  59.     | timedate item
  60.     ;
  61.  
  62. item:    tspec
  63.         {timeflag++;}
  64.     | zone
  65.         {zoneflag++;}
  66.     | dtspec
  67.         {dateflag++;}
  68.     | dyspec
  69.         {dayflag++;}
  70.     | rspec
  71.         {relflag++;}
  72.     | nspec;
  73.  
  74. nspec:    NUMBER
  75.         {if (timeflag && dateflag && !relflag) year = $1;
  76.         else if ($1 > 10000) {
  77.             dateflag++;
  78.             day= $1%100;
  79.             month= ($1/100)%100;
  80.             year = month/10000;
  81.         } else {timeflag++;hh = $1/100;mm = $1%100;ss = 0;merid = 24;}};
  82.  
  83. tspec:    NUMBER MERIDIAN
  84.         {hh = $1; mm = 0; ss = 0; merid = $2;}
  85.     | NUMBER ':' NUMBER
  86.         {hh = $1; mm = $3; merid = 24;}
  87.     | NUMBER ':' NUMBER MERIDIAN
  88.         {hh = $1; mm = $3; merid = $4;}
  89.     | NUMBER ':' NUMBER NUMBER
  90.         {hh = $1; mm = $3; merid = 24;
  91.         day_light = STANDARD; ourzone = -($4%100 + 60*($4/100));}
  92.     | NUMBER ':' NUMBER ':' NUMBER
  93.         {hh = $1; mm = $3; ss = $5; merid = 24;}
  94.     | NUMBER ':' NUMBER ':' NUMBER MERIDIAN
  95.         {hh = $1; mm = $3; ss = $5; merid = $6;}
  96.     | NUMBER ':' NUMBER ':' NUMBER NUMBER
  97.         {hh = $1; mm = $3; ss = $5; merid = 24;
  98.         day_light = STANDARD; ourzone = -($6%100 + 60*($6/100));};
  99.  
  100. zone:    ZONE
  101.         {ourzone = $1; day_light = STANDARD;}
  102.     | DAYZONE
  103.         {ourzone = $1; day_light = DAYLIGHT;};
  104.  
  105. dyspec:    DAY
  106.         {dayord = 1; dayreq = $1;}
  107.     | DAY ','
  108.         {dayord = 1; dayreq = $1;}
  109.     | NUMBER DAY
  110.         {dayord = $1; dayreq = $2;};
  111.  
  112. dtspec:    NUMBER '/' NUMBER
  113.         {month = $1; day = $3;}
  114.     | NUMBER '/' NUMBER '/' NUMBER
  115.         {month = $1; day = $3; year = $5;}
  116.     | MONTH NUMBER
  117.         {month = $1; day = $2;}
  118.     | MONTH NUMBER ',' NUMBER
  119.         {month = $1; day = $2; year = $4;}
  120.     | NUMBER MONTH
  121.         {month = $2; day = $1;}
  122.     | NUMBER MONTH NUMBER
  123.         {month = $2; day = $1; year = $3;};
  124.  
  125.  
  126. rspec:    NUMBER UNIT
  127.         {relsec +=  60L * $1 * $2;}
  128.     | NUMBER MUNIT
  129.         {relmonth += $1 * $2;}
  130.     | NUMBER SUNIT
  131.         {relsec += $1;}
  132.     | UNIT
  133.         {relsec +=  60L * $1;}
  134.     | MUNIT
  135.         {relmonth += $1;}
  136.     | SUNIT
  137.         {relsec++;}
  138.     | rspec AGO
  139.         {relsec = -relsec; relmonth = -relmonth;};
  140. %%
  141.  
  142. static int mdays[12] =
  143.     {31, 0, 31,  30, 31, 30,  31, 31, 30,  31, 30, 31};
  144. #define epoch 1970
  145.  
  146. extern struct tm *localtime();
  147.  
  148. static time_t
  149. dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
  150. int mm, dd, yy, h, m, s, mer, zone, dayflag;
  151. {
  152.     time_t tod, jdate;
  153.     register int i;
  154.  
  155.     if (yy < 0) yy = -yy;
  156.     if (yy < 100) yy += 1900;
  157.     mdays[1] = 28 + (yy%4 == 0 && (yy%100 != 0 || yy%400 == 0));
  158.     if (yy < epoch || yy > 1999 || mm < 1 || mm > 12 ||
  159.         dd < 1 || dd > mdays[--mm]) return (-1);
  160.     jdate = dd-1;
  161.         for (i=0; i<mm; i++) jdate += mdays[i];
  162.     for (i = epoch; i < yy; i++) jdate += 365 + (i%4 == 0);
  163.     jdate *= daysec;
  164.     jdate += zone * 60L;
  165.     if ((tod = timeconv(h, m, s, mer)) < 0) return (-1);
  166.     jdate += tod;
  167.     if (dayflag==DAYLIGHT || (dayflag==MAYBE&&localtime(&jdate)->tm_isdst))
  168.         jdate += -1*60*60;
  169.     return (jdate);
  170. }
  171.  
  172. static time_t
  173. dayconv(ord, day, now)
  174. int ord, day; time_t now;
  175. {
  176.     register struct tm *loctime;
  177.     time_t tod;
  178.  
  179.     tod = now;
  180.     loctime = localtime(&tod);
  181.     tod += daysec * ((day - loctime->tm_wday + 7) % 7);
  182.     tod += 7*daysec*(ord<=0?ord:ord-1);
  183.     return daylcorr(tod, now);
  184. }
  185.  
  186. static time_t
  187. timeconv(hh, mm, ss, mer)
  188. register int hh, mm, ss, mer;
  189. {
  190.     if (mm < 0 || mm > 59 || ss < 0 || ss > 59) return (-1);
  191.     switch (mer) {
  192.         case AM: if (hh < 1 || hh > 12) return(-1);
  193.              return (60L * ((hh%12)*60L + mm)+ss);
  194.         case PM: if (hh < 1 || hh > 12) return(-1);
  195.              return (60L * ((hh%12 +12)*60L + mm)+ss);
  196.         case 24: if (hh < 0 || hh > 23) return (-1);
  197.              return (60L * (hh*60L + mm)+ss);
  198.         default: return (-1);
  199.     }
  200. }
  201.  
  202. static time_t
  203. monthadd(sdate, relmonth)
  204. time_t sdate, relmonth;
  205. {
  206.     struct tm *ltime;
  207.     time_t dateconv();
  208.     int mm, yy;
  209.  
  210.     if (relmonth == 0) return 0;
  211.     ltime = localtime(&sdate);
  212.     mm = 12*ltime->tm_year + ltime->tm_mon + relmonth;
  213.     yy = mm/12;
  214.     mm = mm%12 + 1;
  215.     return daylcorr(dateconv(mm, ltime->tm_mday, yy, ltime->tm_hour,
  216.         ltime->tm_min, ltime->tm_sec, 24, ourzone, MAYBE), sdate);
  217. }
  218.  
  219. static time_t
  220. daylcorr(future, now)
  221. time_t future, now;
  222. {
  223.     int fdayl, nowdayl;
  224.  
  225.     nowdayl = (localtime(&now)->tm_hour+1) % 24;
  226.     fdayl = (localtime(&future)->tm_hour+1) % 24;
  227.     return (future-now) + 60L*60L*(nowdayl-fdayl);
  228. }
  229.  
  230. static char *lptr;
  231.  
  232. static yylex()
  233. {
  234.     extern int yylval;
  235.     int sign;
  236.     register char c;
  237.     register char *p;
  238.     char idbuf[20];
  239.     int pcnt;
  240.  
  241.     for (;;) {
  242.         while (isspace(*lptr))
  243.             lptr++;
  244.  
  245.         if (isdigit(c = *lptr) || c == '-' || c == '+') {
  246.             if (c== '-' || c == '+') {
  247.                 if (c=='-') sign = -1;
  248.                 else sign = 1;
  249.                 if (!isdigit(*++lptr)) {
  250.                     /* yylval = sign; return (NUMBER); */
  251.                     return yylex();    /* skip the '-' sign */
  252.                 }
  253.             } else sign = 1;
  254.             yylval = 0;
  255.             while (isdigit(c = *lptr++))
  256.                 yylval = 10*yylval + c - '0';
  257.             yylval *= sign;
  258.             lptr--;
  259.             return (NUMBER);
  260.  
  261.         } else if (isalpha(c)) {
  262.             p = idbuf;
  263.             while (isalpha(c = *lptr++) || c=='.')
  264.                 if (p < &idbuf[sizeof(idbuf)-1]) *p++ = c;
  265.             *p = '\0';
  266.             lptr--;
  267.             return (lookup(idbuf));
  268.         }
  269.  
  270.         else if (c == '(') {
  271.             pcnt = 0;
  272.             do {
  273.                 c = *lptr++;
  274.                 if (c == '\0') return(c);
  275.                 else if (c == '(') pcnt++;
  276.                 else if (c == ')') pcnt--;
  277.             } while (pcnt > 0);
  278.         }
  279.  
  280.         else return (*lptr++);
  281.     }
  282. }
  283.  
  284. struct table {
  285.     char *name;
  286.     int type, value;
  287. };
  288.  
  289. static struct table mdtab[] = {
  290.     {"january", MONTH, 1},
  291.     {"february", MONTH, 2},
  292.     {"march", MONTH, 3},
  293.     {"april", MONTH, 4},
  294.     {"may", MONTH, 5},
  295.     {"june", MONTH, 6},
  296.     {"july", MONTH, 7},
  297.     {"august", MONTH, 8},
  298.     {"september", MONTH, 9},
  299.     {"sept", MONTH, 9},
  300.     {"october", MONTH, 10},
  301.     {"november", MONTH, 11},
  302.     {"december", MONTH, 12},
  303.  
  304.     {"sunday", DAY, 0},
  305.     {"monday", DAY, 1},
  306.     {"tuesday", DAY, 2},
  307.     {"tues", DAY, 2},
  308.     {"wednesday", DAY, 3},
  309.     {"wednes", DAY, 3},
  310.     {"thursday", DAY, 4},
  311.     {"thur", DAY, 4},
  312.     {"thurs", DAY, 4},
  313.     {"friday", DAY, 5},
  314.     {"saturday", DAY, 6},
  315.     {0, 0, 0}};
  316.  
  317. #define HRS *60
  318. #define HALFHR 30
  319.  
  320. static struct table mztab[] = {
  321.     {"a.m.", MERIDIAN, AM},
  322.     {"am", MERIDIAN, AM},
  323.     {"p.m.", MERIDIAN, PM},
  324.     {"pm", MERIDIAN, PM},
  325.     {"nst", ZONE, 3 HRS + HALFHR},        /* Newfoundland */
  326.     {"n.s.t.", ZONE, 3 HRS + HALFHR},
  327.     {"ast", ZONE, 4 HRS},        /* Atlantic */
  328.     {"a.s.t.", ZONE, 4 HRS},
  329.     {"adt", DAYZONE, 4 HRS},
  330.     {"a.d.t.", DAYZONE, 4 HRS},
  331.     {"est", ZONE, 5 HRS},        /* Eastern */
  332.     {"e.s.t.", ZONE, 5 HRS},
  333.     {"edt", DAYZONE, 5 HRS},
  334.     {"e.d.t.", DAYZONE, 5 HRS},
  335.     {"cst", ZONE, 6 HRS},        /* Central */
  336.     {"c.s.t.", ZONE, 6 HRS},
  337.     {"cdt", DAYZONE, 6 HRS},
  338.     {"c.d.t.", DAYZONE, 6 HRS},
  339.     {"mst", ZONE, 7 HRS},        /* Mountain */
  340.     {"m.s.t.", ZONE, 7 HRS},
  341.     {"mdt", DAYZONE, 7 HRS},
  342.     {"m.d.t.", DAYZONE, 7 HRS},
  343.     {"pst", ZONE, 8 HRS},        /* Pacific */
  344.     {"p.s.t.", ZONE, 8 HRS},
  345.     {"pdt", DAYZONE, 8 HRS},
  346.     {"p.d.t.", DAYZONE, 8 HRS},
  347.     {"yst", ZONE, 9 HRS},        /* Yukon */
  348.     {"y.s.t.", ZONE, 9 HRS},
  349.     {"ydt", DAYZONE, 9 HRS},
  350.     {"y.d.t.", DAYZONE, 9 HRS},
  351.     {"hst", ZONE, 10 HRS},        /* Hawaii */
  352.     {"h.s.t.", ZONE, 10 HRS},
  353.     {"hdt", DAYZONE, 10 HRS},
  354.     {"h.d.t.", DAYZONE, 10 HRS},
  355.  
  356.     {"gmt", ZONE, 0 HRS},
  357.     {"g.m.t.", ZONE, 0 HRS},
  358.     {"bst", DAYZONE, 0 HRS},        /* British Summer Time */
  359.     {"b.s.t.", DAYZONE, 0 HRS},
  360.     {"eet", ZONE, 0 HRS},        /* European Eastern Time */
  361.     {"e.e.t.", ZONE, 0 HRS},
  362.     {"eest", DAYZONE, 0 HRS},    /* European Eastern Summer Time */
  363.     {"e.e.s.t.", DAYZONE, 0 HRS},
  364.     {"met", ZONE, -1 HRS},        /* Middle European Time */
  365.     {"m.e.t.", ZONE, -1 HRS},
  366.     {"mest", DAYZONE, -1 HRS},    /* Middle European Summer Time */
  367.     {"m.e.s.t.", DAYZONE, -1 HRS},
  368.     {"wet", ZONE, -2 HRS },        /* Western European Time */
  369.     {"w.e.t.", ZONE, -2 HRS },
  370.     {"west", DAYZONE, -2 HRS},    /* Western European Summer Time */
  371.     {"w.e.s.t.", DAYZONE, -2 HRS},
  372.  
  373.     {"jst", ZONE, -9 HRS},        /* Japan Standard Time */
  374.     {"j.s.t.", ZONE, -9 HRS},    /* Japan Standard Time */
  375.                     /* No daylight savings time */
  376.  
  377.     {"aest", ZONE, -10 HRS},    /* Australian Eastern Time */
  378.     {"a.e.s.t.", ZONE, -10 HRS},
  379.     {"aesst", DAYZONE, -10 HRS},    /* Australian Eastern Summer Time */
  380.     {"a.e.s.s.t.", DAYZONE, -10 HRS},
  381.     {"acst", ZONE, -(9 HRS + HALFHR)},    /* Australian Central Time */
  382.     {"a.c.s.t.", ZONE, -(9 HRS + HALFHR)},
  383.     {"acsst", DAYZONE, -(9 HRS + HALFHR)},    /* Australian Central Summer */
  384.     {"a.c.s.s.t.", DAYZONE, -(9 HRS + HALFHR)},
  385.     {"awst", ZONE, -8 HRS},        /* Australian Western Time */
  386.     {"a.w.s.t.", ZONE, -8 HRS},    /* (no daylight time there, I'm told */
  387.     {0, 0, 0}};
  388.  
  389. static struct table unittb[] = {
  390.     {"year", MUNIT, 12},
  391.     {"month", MUNIT, 1},
  392.     {"fortnight", UNIT, 14*24*60},
  393.     {"week", UNIT, 7*24*60},
  394.     {"day", UNIT, 1*24*60},
  395.     {"hour", UNIT, 60},
  396.     {"minute", UNIT, 1},
  397.     {"min", UNIT, 1},
  398.     {"second", SUNIT, 1},
  399.     {"sec", SUNIT, 1},
  400.     {0, 0, 0}};
  401.  
  402. static struct table othertb[] = {
  403.     {"tomorrow", UNIT, 1*24*60},
  404.     {"yesterday", UNIT, -1*24*60},
  405.     {"today", UNIT, 0},
  406.     {"now", UNIT, 0},
  407.     {"last", NUMBER, -1},
  408.     {"this", UNIT, 0},
  409.     {"next", NUMBER, 2},
  410.     {"first", NUMBER, 1},
  411.     /* {"second", NUMBER, 2}, */
  412.     {"third", NUMBER, 3},
  413.     {"fourth", NUMBER, 4},
  414.     {"fifth", NUMBER, 5},
  415.     {"sixth", NUMBER, 6},
  416.     {"seventh", NUMBER, 7},
  417.     {"eigth", NUMBER, 8},
  418.     {"ninth", NUMBER, 9},
  419.     {"tenth", NUMBER, 10},
  420.     {"eleventh", NUMBER, 11},
  421.     {"twelfth", NUMBER, 12},
  422.     {"ago", AGO, 1},
  423.     {0, 0, 0}};
  424.  
  425. static struct table milzone[] = {
  426.     {"a", ZONE, 1 HRS},
  427.     {"b", ZONE, 2 HRS},
  428.     {"c", ZONE, 3 HRS},
  429.     {"d", ZONE, 4 HRS},
  430.     {"e", ZONE, 5 HRS},
  431.     {"f", ZONE, 6 HRS},
  432.     {"g", ZONE, 7 HRS},
  433.     {"h", ZONE, 8 HRS},
  434.     {"i", ZONE, 9 HRS},
  435.     {"k", ZONE, 10 HRS},
  436.     {"l", ZONE, 11 HRS},
  437.     {"m", ZONE, 12 HRS},
  438.     {"n", ZONE, -1 HRS},
  439.     {"o", ZONE, -2 HRS},
  440.     {"p", ZONE, -3 HRS},
  441.     {"q", ZONE, -4 HRS},
  442.     {"r", ZONE, -5 HRS},
  443.     {"s", ZONE, -6 HRS},
  444.     {"t", ZONE, -7 HRS},
  445.     {"u", ZONE, -8 HRS},
  446.     {"v", ZONE, -9 HRS},
  447.     {"w", ZONE, -10 HRS},
  448.     {"x", ZONE, -11 HRS},
  449.     {"y", ZONE, -12 HRS},
  450.     {"z", ZONE, 0 HRS},
  451.     {0, 0, 0}};
  452.  
  453. static 
  454. lookup(id)
  455. char *id;
  456. {
  457. #define gotit (yylval=i->value,  i->type)
  458.  
  459.     char idvar[128];
  460.     register char *j, *k;
  461.     register struct table *i;
  462.     int abbrev;
  463.  
  464.     (void) strcpy(idvar, id);
  465.     j = idvar;
  466.     k = id - 1;
  467.     while (*++k)
  468.         *j++ = isupper(*k) ? tolower(*k) : *k;
  469.     *j = '\0';
  470.  
  471.     if (strlen(idvar) == 3)
  472.         abbrev = 1;
  473.     else
  474.         if (strlen(idvar) == 4 && idvar[3] == '.') {
  475.             abbrev = 1;
  476.             idvar[3] = '\0';
  477.         }
  478.     else
  479.         abbrev = 0;
  480.  
  481.     for (i = mdtab; i->name; i++) {
  482.         k = idvar;
  483.         for (j = i->name; *j++ == *k++;) {
  484.             if (abbrev && j == i->name+3)
  485.                 return gotit;
  486.             if (j[-1] == 0)
  487.                 return gotit;
  488.         }
  489.     }
  490.  
  491.     for (i = mztab; i->name; i++)
  492.         if (strcmp(i->name, idvar) == 0)
  493.             return gotit;
  494.  
  495.     for (i=mztab; i->name; i++)
  496.         if (strcmp(i->name, idvar) == 0)
  497.             return gotit;
  498.  
  499.     for (i=unittb; i->name; i++)
  500.         if (strcmp(i->name, idvar) == 0)
  501.             return gotit;
  502.  
  503.     if (idvar[strlen(idvar)-1] == 's')
  504.         idvar[strlen(idvar)-1] = '\0';
  505.  
  506.     for (i=unittb; i->name; i++)
  507.         if (strcmp(i->name, idvar) == 0)
  508.             return gotit;
  509.  
  510.     for (i = othertb; i->name; i++)
  511.         if (strcmp(i->name, idvar) == 0)
  512.             return gotit;
  513.  
  514.     if (strlen(idvar) == 1 && isalpha(*idvar)) {
  515.         for (i = milzone; i->name; i++)
  516.             if (strcmp(i->name, idvar) == 0)
  517.                 return gotit;
  518.     }
  519.  
  520.     return ID;
  521. }
  522.  
  523. time_t
  524. getdate(p, now)
  525. char *p;
  526. struct timeb *now;
  527. {
  528. #define mcheck(f)    if (f>1) err++
  529.     time_t monthadd();
  530.     int err;
  531.     struct tm *lt;
  532.     struct timeb ftz;
  533.  
  534.     time_t sdate, tod;
  535.  
  536.     lptr = p;
  537.     if (now == ((struct timeb *) NULL)) {
  538.         now = &ftz;
  539.         ftime(&ftz);
  540.     }
  541.     lt = localtime(&now->time);
  542.     year = lt->tm_year;
  543.     month = lt->tm_mon+1;
  544.     day = lt->tm_mday;
  545.     relsec = 0; relmonth = 0;
  546.     timeflag=zoneflag=dateflag=dayflag=relflag=0;
  547.     ourzone = now->timezone;
  548.     day_light = MAYBE;
  549.     hh = mm = ss = 0;
  550.     merid = 24;
  551.  
  552.     if (err = yyparse()) return (-1);
  553.  
  554.     mcheck(timeflag);
  555.     mcheck(zoneflag);
  556.     mcheck(dateflag);
  557.     mcheck(dayflag);
  558.  
  559.     if (err) return (-1);
  560.     if (dateflag || timeflag || dayflag) {
  561.         sdate = dateconv(month,day,year,hh,mm,ss,merid,ourzone,day_light);
  562.         if (sdate < 0) return -1;
  563.     }
  564.     else {
  565.         sdate = now->time;
  566.         if (relflag == 0)
  567.             sdate -= (lt->tm_sec + lt->tm_min*60 +
  568.                 lt->tm_hour*(60L*60L));
  569.     }
  570.  
  571.     sdate += relsec;
  572.     sdate += monthadd(sdate, relmonth);
  573.  
  574.     if (dayflag && !dateflag) {
  575.         tod = dayconv(dayord, dayreq, sdate);
  576.         sdate += tod;
  577.     }
  578.  
  579.     /*
  580.     ** Have to do *something* with a legitimate -1 so it's distinguishable
  581.     ** from the error return value.  (Alternately could set errno on error.)
  582.     */
  583.     return (sdate == -1) ? 0 : sdate;
  584. }
  585.  
  586. static
  587. yyerror(s)
  588. char *s;
  589. {
  590. }
  591.  
  592. #ifdef USG
  593. ftime(timeb)
  594. struct timeb *timeb;
  595. {
  596.     extern long timezone;
  597.     extern int daylight;
  598.     long t = 0;
  599.  
  600.     localtime(&t);    /* Dummy to init timzeone */
  601.     time(&(timeb->time));
  602.     timeb->millitm=0;
  603.     timeb->timezone=timezone/60;    /* Timezone is in seconds! */
  604.     timeb->dstflag=daylight;
  605. }
  606. #endif
  607.